package xmysql

import (
	"database/sql"

	"gitee.com/githubdog/goci/libraries/clients/xssh"
	"golang.org/x/crypto/ssh"
)

const (
	protocolTCP = "tcp"
	protocolSSH = "mysql+tcp"
)

type DBPoolConf struct {
	ConnMaxLifetime int // 最大连接时长
	MaxOpenConns    int // 最大打开的连接数
	MaxIdleConns    int // 最大闲置的连接数
}

// DBConf ..
type DBConf struct {
	Username string
	Password string
	Host     string
	DBname   string
	Prefix   string
	/**
	| allowAllFiles  Default: false
	| allowCleartextPasswords  Default: false
	| allowNativePasswords  Defalut: true
	| allowOldPasswords  Defalut: false
	| charset  Defalult: Defalut: <none>, eg: utf8mb4、utf8
	| checkConnLiveness  Defalut: true
	| collation Defalut: utf8mb4_general_ci
	| clientFoundRows  Defalut: false
	| clientFoundRows  Defalut: false
	| interpolateParams  Defalut: false
	| loc  Default: UTC, eg: Local、America/New_York
	| maxAllowedPacket  Defalut: 4194304 byte
	| multiStatements  Defalut: false
	| parseTime  Defalut: false
	| readTimeout  Defalut: 0
	| rejectReadOnly  Defalut: false
	| serverPubKey  Defalut: <none>
	| timeout  Defalut: OS defalut
	| tls  Defalut: false
	| writeTimeout  Defalut: 0
	*/
	Other map[string]string
	DBPoolConf
}

// DbTCP ..
type DbTCP struct {
	DbClient *sql.DB
	Conf     DBConf
	DSN      string
	ConnUUID string
	Version  string
}

// DbSSH ..
type DbSSH struct {
	DbTCP
	SSHConf   xssh.SSHConf
	SSHClient *ssh.Client
}

// DbGroup ..
type DbGroup struct {
	Name     string
	TCP      DbTCP
	SSH      DbSSH
	ConnType string
	// IsPrint bool
}
